﻿/* ***********************************************
 * Author		:  kingthy
 * Email		:  kingthy@gmail.com
 * Description	:  ResponseData
 *
 * ***********************************************/

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Reflection;

namespace OpenTwitter.SDK.Sina.Objects
{
    /// <summary>
    /// 服务端输出的结果数据
    /// </summary>
    public class ResponseData : ResponseObject
    {
        /// <summary>
        /// 根据XML数据实例化
        /// </summary>
        /// <param name="xml">XML数据</param>
        internal ResponseData(XmlNode xml)
            : base(xml)
        { }
        /// <summary>
        /// 错误信息
        /// </summary>
        public string ErrorMessage { get; private set; }

        /// <summary>
        /// 错误码.如果为0则表示没有错误
        /// </summary>
        public int ErrorCode { get; private set; }

        /// <summary>
        /// 解析XML文档数据
        /// </summary>
        protected override void Parse()
        {
            this.ErrorMessage = Util.GetXmlNodeValue<string>(this.Xml.SelectSingleNode("error"));
            this.ErrorCode = Util.GetXmlNodeValue<int>(this.Xml.SelectSingleNode("error_code"));
        }
    }
}
